home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Tech Arsenal 1
/
Tech Arsenal (Arsenal Computer).ISO
/
tek-02
/
tsptp.zip
/
SIEVE.PAS
< prev
next >
Wrap
Pascal/Delphi Source File
|
1993-04-09
|
3KB
|
92 lines
(******************************************************************************)
(* SIEVE.PAS *)
(* Sieve Benchmark. *)
(******************************************************************************)
PROGRAM SIEVE(Output);
(******************************************************************************)
(* TIMING *)
(******************************************************************************)
(*$IFNDEF TopSpeed *)
(*%F TRUE *** Compile for Turbo Pascal ***)
USES TPBench;
(*%E*)
(*$ELSE *** Compile for TopSpeed Pascal ***)
IMPORT TSBench *;
(*$ENDIF *)
(******************************************************************************)
CONST
Size = 8190;
VAR
Count : BmInt;
Flags : ARRAY [0..Size] OF BOOLEAN;
PROCEDURE SieveProc;
VAR I, J, K, Prime : BmInt;
BEGIN
Count := 0;
FOR I := 0 TO Size DO
Flags[I] := TRUE;
FOR I := 0 TO Size DO
BEGIN
IF Flags[I] THEN
BEGIN
Prime := 2 * I + 3;
K := I + Prime;
WHILE K <= Size DO
BEGIN
Flags[K] := FALSE;
K := K + Prime
END;
Count := Count + 1;
END
END
END;
BEGIN
WriteLn('Sieve Benchmark');
(******************************************************************************)
(* Compute the looping overhead. The Dummy procedure must have some side- *)
(* effect so that it is not optimised out of existence. *)
(******************************************************************************)
StartTimer; (* Start the clock. *)
REPEAT
Dummy;
UNTIL NullTimesUp;
(******************************************************************************)
(* Now run the benchmark. Note that the Dummy procedure is also called so *)
(* that we can eliminate its overhead from the looping overhead. *)
(******************************************************************************)
StartTimer; (* Start the clock. *)
REPEAT
SieveProc;
Dummy
UNTIL BenchTimesUp;
(******************************************************************************)
ReportTimes;
WriteLn;
IF Count <> 1899 THEN
WriteLn('Fail')
ELSE
WriteLn('Pass');
END.